package com.didispace.mytest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * 工具类：负责向中间件发送数据
 */
@EnableBinding(MyProcessor.class)
@Component
public class MessageSender {

    @Autowired
    @Qualifier(value = "myoutput")
    private MessageChannel myoutput;
    
    @Autowired
    @Qualifier(value = "xiongoutput")
    private MessageChannel xiongoutput;
    
    @Autowired
    private MessageChannel output;

    //发送消息
    public void send(Object obj){
        myoutput.send(MessageBuilder.withPayload("myoutput:"+obj).build());
        xiongoutput.send(MessageBuilder.withPayload("xiongoutput:"+obj).build());
        output.send(MessageBuilder.withPayload("output:"+obj).build());
    }
}
    